#!/bin/bash -e

d=$1
dir=$(dirname ${d})

f=$(mktemp)
./print_deb_source.sed "$d" > ${f}

pkg=$(head -n 1 ${f})
echo "processing package: ${pkg} ..."

osc mkpac ${pkg}
pushd ${pkg}
cp ${d} .

tail -n +2 ${f} | while read i
do
  #echo "cp ${i}"
  cp ${dir}/${i} .
done
rm -f ${f}

osc add *
osc ci -m "add deb package ${d}"
popd
